import * as http from '@api/http'

/**
 * @purpose 获取活动订单
 * @param status
 * @param page
 * @param size
 * @returns {*}
 */
export function items (status, page, size) {
  return http
    .get('activityOrder.items', {
      status: status,
      page: page,
      size: size
    })
    .then(r => r.data)
}

/**
 * @purpose 编辑出行人
 * @param attach
 * @returns {Promise<T>}
 */
export function editAttach (attach) {
  return http
    .post('activityOrder.editAttach', attach)
    .then(r => r.data)
}

/**
 * @purpose 获取订单详情
 * @param orderNo
 * @returns {*}
 */
export function detail (orderNo) {
  return http
    .get('activityOrder.detail', {
      order_no: orderNo
    })
    .then(r => r.data)
}

/**
 * @purpose 未支付时取消出行人
 * @param attachId
 * @param reason
 * @returns {Promise<T>}
 */
export function cancelTravelByNotPay (attachId, reason) {
  return http
    .post('activityOrder.cancelTravelByNotPay', {
      attach_id: attachId,
      reason: reason
    })
    .then(r => r.data)
}
/**
 * @purpose 取消出行人并退款
 * @param attachId
 * @param reason
 * @returns {Promise<T>}
 */
export function cancelTravelByPay (attachId, reason) {
  return http
    .post('activityOrder.cancelTravelByPay', {
      attach_id: attachId,
      reason: reason
    })
    .then(r => r.data)
}

/**
 * @purpose 未支付时取消订单
 * @param orderNo
 * @param reason
 * @returns {Promise<T>}
 */
export function cancelByNotPay (orderNo, reason) {
  return http
    .post('activityOrder.cancelByNotPay', {
      order_no: orderNo,
      reason: reason
    })
    .then(r => r.data)
}

/**
 * @purpose 取消已支付订单
 * @param orderNo
 * @param reason
 * @returns {Promise<T>}
 */
export function cancelByPay (orderNo, reason) {
  return http
    .post('activityOrder.cancelByPay', {
      order_no: orderNo,
      reason: reason
    })
    .then(r => r.data)
}

/**
 * @purpose 通过团期ID获取订单信息
 * @param groupStageId
 * @returns {*}
 */
export function itemsByGroupStage (groupStageId) {
  return http
    .get('activityOrder.itemsByGroupStage', {
      group_stage_id: groupStageId
    })
    .then(r => r.data)
}
